package com.extension.company.common.utils;

import com.extension.company.KEY;

/**
 * 作者:zwk
 * 联系方式：497981239@qq.com
 * 时间：on 2019/8/8 11:11
 * 功能：
 */
public class WXSingUtils {
	/**
	 * @param partnerId    商户名
	 * @param prepayId     预支付交易id
	 * @param packageValue Sing=WXPay
	 * @param nonceStr     随机数
	 * @param timeStamp    时间戳
	 * @param key          商户的key
	 * @return 加密后的sign
	 */
	public static String signNum(String partnerId, String prepayId, String packageValue, String nonceStr, String timeStamp, String key) {
		String stringA =
				"appid=" + KEY.WX_PAY_ID
						+ "&noncestr=" + nonceStr
						+ "&package=" + packageValue
						+ "&partnerid=" + partnerId
						+ "&prepayid=" + prepayId
						+ "&timestamp=" + timeStamp;
		String stringSignTemp = stringA + "&key=" + key;
		return MD5.getMessageDigest(stringSignTemp.getBytes()).toUpperCase();
	}

}
